package com.situ.day8;

import java.math.MathContext;

import org.junit.Test;

public class Demo {

	@Test
	public void test1() {
		Student student1 = new Student(1, "张三", 23, "CN");
		Student student2 = new Student(2, "李四", 21, "CN");
		student1.print();
//		System.out.println(student1.country);
		System.out.println(Student.country);
//		student1.show();
		Student.show();
	}

	@Test
	public void test2() {
		String str1 = "abc";
		String str2 = new String("abc");
		String str3 = "abc";
		System.out.println(str1 == str2);
		System.out.println(str2 == str3);
		System.out.println(str1 == str3);
	}

	@Test
	public void test3() {
		String str = "Java Is A WorldA";
		System.out.println(str.length());
		char[] array = str.toCharArray();
		char ch = str.charAt(5);
		System.out.println(ch);

		System.out.println(str.indexOf('A'));
		System.out.println(str.indexOf('X'));
		System.out.println(str.indexOf('A', 6));
		System.out.println(str.indexOf("Wor"));

		System.out.println(str.lastIndexOf('A'));

	}

	@Test
	public void test4() {
		String str = "Java Is A WorldA";
		System.out.println(str.contains("Wor"));
		System.out.println(str.startsWith("Java"));
		System.out.println(str.startsWith("Wor", 10));
		System.out.println(str.endsWith("rldA"));
		System.out.println(str.isEmpty());
		System.out.println("".isEmpty());
	}

	@Test
	public void test5() {
		char[] array = { 'j', 'a', 'v', 'a', ' ', 'A', 'n', 'd' };
		//将数组转换成字符串
		String str = new String(array);
		System.out.println(str);
		//将字符串转换为数组
		char[] charArray = str.toCharArray();
		for (char c : charArray) {
			System.out.print(c + " ");
		}
	}

	@Test
	public void test6() {
		String str = "Java Is A WorldA";
		String newStr = str.replace('A', 'B');
		System.out.println(str);
		System.out.println(newStr);
	}

	@Test
	public void test7() {
		String str = "java AndroidA Python";
		String[] array = str.split(" ");
		for (String string : array) {
			System.out.println(string);
		}
	}

	@Test
	public void test8() {
		String str = "Java Is A WorldA";
		System.out.println(str.substring(5));// Is A WorldA
		System.out.println(str.substring(5, 9));// Is A
	}

	@Test
	public void test9() {
		String str = "   Java Is A WorldA   ";
		System.out.println(str);// Java Is A WorldA
		System.out.println(str.trim());// Java Is A WorldA
	}

	@Test
	public void test10() {
		String str = "java,Android,Python";
		String[] array = str.split(",");
		for (int i = 0; i < array.length; i++) {
			System.out.println(array[i]);
		}

		System.out.println("--------------");
		for (String string : array) {
			System.out.println(string);
		}
	}

	@Test
	public void test11() {
		String str1 = "Hello";
		String str2 = "Java";
		String str3 = "Android";
		String str4 = "Python";
		String str = str1 + str2 + str3 + str4;
		System.out.println(str);
	}

	@Test
	public void test12() {
		String str1 = "Hello";
		String str2 = "Java";
		String str3 = "Android";
		String str4 = "Python";
		StringBuilder builder = new StringBuilder(str1);
		builder.append(str2);
		builder.append(str3);
		builder.append(str4);
		System.out.println(builder);
	}
	
}
